<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      * {
        margin: 0px;
        padding: 0px;
      }
      .box {
        width: 800px;
        height: 600px;
        border: 1px solid black;
        position: relative;
        top: 0px;
        left: 0px;
      }
      .box1 {
        width: 300px;
        height: 500px;
        border: 1px solid black;
        float: left;
      }
      .header {
        width: 300px;
        height: 80px;
        border: 1px solid black;
      }

      .box1 li {
        width: 260px;
        height: 50px;
        border: 1px solid black;
        margin-left: 15px;
        margin-top: 10px;
        list-style: none;
        text-align: center;
        line-height: 50px;
      }
      /* .box1 li:nth-child(1) {
        position: absolute;
        top: 90px;
        left: 0px;
      }
      .box1 li:nth-child(2) {
        position: absolute;
        top: 150px;
        left: 0px;
      }
      .box1 li:nth-child(3) {
        position: absolute;
        top: 210px;
        left: 0px;
      } */
      .box2 {
        width: 300px;
        height: 500px;
        border: 1px solid black;
        float: right;
        margin-right: 180px;
      }
      .end {
        width: 300px;
        height: 80px;
        border: 1px solid black;
      }
    </style>
  </head>
  <body>
    <div class="box">
      <div class="box1">
        <div class="header">代办的</div>
        <ul class="new">
          <li>任务一</li>
          <li>任务二</li>
          <li>任务三</li>
        </ul>
      </div>
      <div class="box2">
        <div class="end">进行中</div>
      </div>
      <input type="text" class="add" /><button>点击添加</button>
    </div>
    <script>
      var ulEle = document.querySelector("ul");
      var addEle = document.querySelector(".add");
      var buttonEle = document.querySelector("button");
      buttonEle.onclick = function () {
        var value = addEle.value;
        var liEle = document.createElement("li");
        liEle.innerHTML = `${value}`;
        ulEle.appendChild(liEle);
      };
      var eles = document.querySelectorAll(".new li");
      eles.onmousedown = function (event) {
        var e = event || window.event;
        var x = e.clientX - eles.offsetLeft;
        var y = e.clientY - eles.offsetTop;

        eles.onmousemove = function (event) {
          var e = event || window.event;
          var xx = e.clientX;
          var yy = e.clientY;

          eles.style.left = xx - x + "px";
          eles.style.top = yy - y + "px";
        };
        eles.onmouseup = function () {
          eles.onmousemove = "";
        };
      };
    </script>
  </body>
</html>
